<template>
	<view class=" h100">
		<view v-if="jieguo == 1 && userinfo">
			<view class="u-p-40 text-center">
						
					<view class="u-p-t-40 u-font-34"><u-icon name="checkbox-mark" class="u-type-primary" style="font-size: 90upx;"></u-icon>认证通过！</view>
					<view class="u-p-t-40 u-tips-color">您好，我是{{userinfo.realname}}，很高兴为您服务，提供一对一服务；
		您可以随时联系我哦！</view>
				<view class="u-p-t-40">
					<image class="text-shadow" :src="userinfo.badgeimgurl" style="border-radius: 30upx;width: 160upx;height: 160upx;"></image>
				</view>
				<view class="u-font-34 u-p-t-20" style="font-weight: 600;">
					{{userinfo.realname}}
				</view>
				<view class="u-p-t-20 u-tips-color mid">
					<image :src="userinfo.level.icon" style="width: 40upx;height: 40upx;"></image><text class="u-p-l-10">{{userinfo.level.str}}</text>
				</view>
				<u-button class="u-m-t-30" style="width: 300upx;" @click="goOrder"><u-icon class="u-font-40" name="phone-fill" style="color: orange;"></u-icon><text class="u-p-l-10">已认证电话</text></u-button>
				<u-button class="u-m-t-30" style="width: 300upx;" @click="goBack">
					<text class="fa fa-id-card-o u-type-primary"></text>
					<text class="u-p-l-10">已实名认证 </text>
				</u-button>
			</view>
		</view>
		<view v-if=" jieguo == 2 ">
			<view class="u-p-40 text-center">
				<view class="u-p-t-40 u-font-34"><u-icon name="warning-fill" class="u-type-error" style="font-size: 90upx;"></u-icon>认证失败！</view>
				<view class="u-p-t-40 u-tips-color">请选择正规服务机构！避免造成经济损失！</view>
			</view>
		</view>
	</view>
</template>

<script>
	import ksjPreviewImage from 'components/kd-preview-image/kd-preview-image.vue';
	export default {
		components: {
			ksjPreviewImage
		},
		data() {
			return {
				url: this.$u.http.config.baseUrl,
				submit_data:{
				},
				userinfo:'',
				jieguo:0
			}
		},
		onLoad: function(e) {
			this.login = false;
			try { 
				//从本地缓存中同步获取指定 key 对应的内容。
				const value = uni.getStorageSync('userinfo');
				if (value && value.length != 0 && e.content && e.content.indexOf("check.varuuu.com") != -1) {
					this.userinfo = value;
					this.login = true;
					this.submit_data._id = this.userinfo['_id'];
					this.getUserInfo();
					return this.jieguo = 1;
				} else {
					return this.jieguo = 2;
					this.userinfo = '';
				}
			} catch (e) {
				console.error(e)
			}
		},
		methods: {
			//返回上一页
			goBack(){
				uni.redirectTo({
					url:"/pages/form/addpreorder"
				})
			},
			goOrder(){
				uni.redirectTo({
					url:"/pages/center/preorder_list?state=0"
				})
			},
			getUserInfo(){
				this.$u.api.getUserInfo(this.submit_data).then(res=>{
					if(res.code == 1){
						this.userinfo = res.data
						return this.jieguo = 1;
					}
				}).catch(res=>{
					return this.jieguo = 2;
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	
	.list {
		padding: 24upx 0;
		border-bottom: 1upx solid #f6f6f6;
	}
	.color-error {
		color: $u-type-error;
	}
	.u-type-primary {
		color: $u-type-primary;
	}
	.u-hairline-border:after{
		border:0 !important
	}
</style>
